package com.sxhnpg.interceptor;

import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.sxhnpg.model.User;

public class LoginInterceptor extends MethodFilterInterceptor{

	public String doIntercept(ActionInvocation invocation) throws Exception {
		String code="login";
		String path=ServletActionContext.getRequest().getServletPath();
		Map<String, Object>session=invocation.getInvocationContext().getSession();
		session.put("path", path);
		User user=(User)session.get("login_user");
		if(user!=null){
			code=invocation.invoke();
		}
		return code;
	}
}
